//
// Created by xidian on 2024/12/25.
//

#ifndef INC_24G_DATAPROCESS_0520_DATASAVE_H
#define INC_24G_DATAPROCESS_0520_DATASAVE_H

#include <memory>
#include <thread>
#include <semaphore.h>
#include <cstring>

#define _N 60

class DataSave
{
public:
    DataSave();
    ~DataSave();

    void startSave();

    void push(uint8_t *data);

private:
    void saveThread();
    std::string getFileName();

    std::shared_ptr<std::thread> thread = nullptr;
    bool isStopped = false;
    bool isStart = false;

    uint8_t buf[_N][1200];
    int readPtr = 0;
    int writePtr = 0;
    sem_t sem;
};

#endif // INC_24G_DATAPROCESS_0520_DATASAVE_H
